<%-- 
    Document   : reporte
    Created on : 19/11/2011, 12:26:01 PM
    Author     : Programador
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="java.sql.*" %>
<%@page import="java.util.*" %>
<%@page import="java.io.*" %>
<%@page import="net.sf.jasperreports.engine.*" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <%
        Connection c;
        String url = "jdbc:sqlserver://UTLAB706\\MSSQLSERVER2;databaseName=Escuela";
        DriverManager.registerDriver(new com.microsoft.sqlserver.jdbc.SQLServerDriver());
        c = DriverManager.getConnection(url,"sa","1234");

        File archivo = new File(application.getRealPath("reportes//report1.jasper"));
        Map parametros = new HashMap();
        parametros.put("nombreparametro", "valorpametro");

        byte[] bytes = JasperRunManager.runReportToPdf(archivo.getPath(), parametros,c);
        response.setContentType("application/pdf");
        response.setContentLength(bytes.length);
        ServletOutputStream os = response.getOutputStream();
        os.write(bytes,0,bytes.length);
        os.flush();
        os.close();

        %>
    </body>
</html>
